package com.mq.dpca.util;

import java.util.ResourceBundle;

public class RenameUtil {
	public static String rename(String name){
		String newname = null;
		if(name!=null&&!"".equals(name.trim())){
			String ss[] = name.split("\\.");
			try {
				ss[0] = ss[0]+"_"+DateFormatUtil.getNowDateTimeByFormat();
				newname = ss[0]+"."+ss[1];
			} catch (Exception e) {
				// TODO: handle exception
				System.out.println("the file name is not right for here");
			}
		}
		return newname;
	}
	public static String getNameByUrl(String filedir){
		int p = filedir.lastIndexOf("\\");
		if(p>1){
			return filedir.substring(p+1, filedir.length());
		}else{
			return null;
		}
		
		
	}
	
	public static String getParameter(ResourceBundle dbCfg, String key) {
		String value = null;
		if(key==null){
			return value;
		}
		try {
			value = dbCfg.getString(key);
		} catch (Exception e) {
			value = null;
		}
		return value;
	}
	public static void main(String[] args) {
//		System.out.println(RenameUtil.rename("11.txt"));
		System.out.println(RenameUtil.getNameByUrl("C:\\Program Files\\Java\\jdk1.6.0_43\\register_ja.html"));
		System.out.println("C:\\Program Files\\Java\\jdk1.6.0_43\\register_ja.html");
	}
	
	public static String getSysForKey(String key){
		if(key!=null&&!"".equals(key.trim())){
			String[] keys = key.split("_");
			return keys[0];
		}
		return null;
	}
}
